﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MuzičkiFeršterker
{
    public static class EngineTypePairs
    {
        private static EngineTypePair[] pairs = new EngineTypePair[]
            {
                new EngineTypePair("mp3", Engine.irrKlang),
                new EngineTypePair("wav", Engine.irrKlang),
                new EngineTypePair("ogg", Engine.irrKlang),
                new EngineTypePair("flac", Engine.irrKlang),
                new EngineTypePair("mod", Engine.irrKlang),
                new EngineTypePair("it", Engine.irrKlang),
                new EngineTypePair("s3d", Engine.irrKlang),
                new EngineTypePair("xm", Engine.irrKlang),
                new EngineTypePair("wma", Engine.MediaElement)
            };

        public static Engine GetEngineFromType(string type)
        {
            if (type.StartsWith("."))
                type = type.Substring(1);
            for(int i=0;i<pairs.Length;i++)
                if(type.ToLower() == pairs[i].Type)
                    return pairs[i].Engine;
            return Engine.ERROR;
        }
    }

    class EngineTypePair
    {
        private string type;
        private Engine engine;

        public EngineTypePair(string type, Engine engine)
        {
            this.type = type;
            this.engine = engine;
        }

        public string Type
        {
            get { return this.type; }
        }

        public Engine Engine
        {
            get { return this.engine; }
        }
    }

    public enum Engine
    { 
        ERROR,
        irrKlang,
        MediaElement
    }
}
